<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/yoyoga.css" media="all"/>
    <script type="text/javascript" src="/layui/layui.js"></script>
    <script type="text/javascript" src="/libs/jquery.min.js"></script>


    <!-- 注意：此页面仅教练能看到，展示教练与场馆之间签的合同 -->
</head>
<body>

<div class="layui-tab main-content-container">
    <ul class="layui-tab-title" style="width: 100%;">
        <li class="layui-this" onclick="showAgreement(0,'agreementListWait')">已申请</li>
        <li onclick="showAgreement(4,'agreementListOnGoing')">进行中</li>
        <li onclick="showAgreement(5,'agreementListFinished')">已解约</li>
        <li onclick="showAgreement(2,'agreementListReject')">已拒绝</li>
    </ul>
    <div class="layui-tab-content"  style="width: 100%;">
        <div class="layui-tab-item layui-show" id="agreementListWait"></div>
        <div class="layui-tab-item" id="agreementListOnGoing"></div>
        <div class="layui-tab-item" id="agreementListFinished"></div>
        <div class="layui-tab-item" id="agreementListReject"></div>
    </div>
</div>



<script>
    layui.use('element', function() {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块

        //监听导航点击
        element.on('nav(demo)', function(elem) {
            //console.log(elem)
            layer.msg(elem.text());
        });
    });
</script>
<script>
    //展示教练与场馆签订的合约
    function showAgreement(aState,id){
        layui.use('flow', function() {
            var flow = layui.flow;
            flow.load({
                elem: '#'+id, //流加载容器
                done: function(page, next) { //执行下一页的回调
                    var lis = [];
                    var agreementState;
                    $.ajax({
                        url:"/trainer/selectAgreement?page="+page+"&aState="+aState,
                        dataType:"json",
                        success:function(res){
                            layui.each(res.currentMessage,function (index, item) {
                                agreementState = agreementStateName(item.ttrainerAgreement.taState);
                                lis.push(
                                    '<div class="mytrainer-card">'
                                    +'<div class="mytrainer-card-left">'
                                    +'<div class="mytrainer-card-gym-trainer">'
                                    +'场馆:'+item.gym.gName
                                    +'</div>'
                                    +'<div class="mytrainer-card-gym-trainer">'
                                    +'场馆抽成比例：10%'
                                    +'</div>'
                                    +'<div class="mytrainer-card-gym-trainer">'
                                    +'发起时间:'+item.ttrainerAgreement.taCreatetime
                                    +'</div>'
                                    +'</div>'
                                    +'<div class="mytrainer-card-right">'
                                    +'状态：'+agreementState
                                    +'</div>'
                                    +'</div>'
                                )
                            });
                            next(lis.join(''), page < res.total);
                        }
                    })

                }
            });
        });
    }

    $(function () {
        showAgreement(0,'agreementListWait');
    });

    function agreementStateName(state){
        switch (state) {
            case 0:
                return '待场馆审核';
            case 1:
                return "待处理";
            case 2:
                return "场馆拒绝了入驻申请";
            case 3:
                return "已拒绝场馆邀请";
            case 4:
                return "签约中";
            case 5:
                return "已解约";
        }
    }

</script>





</body>

</html>
